package com.dfbz.demo05_泛型通配符;

/**
 * @author lscl
 * @version 1.0
 * @intro:
 */
public class Demo01 {
    public static void main(String[] args) {

        TestClass<Number> testClass1=new TestClass<>();
        test1(testClass1);

        TestClass<Integer> testClass2=new TestClass<>();
        test1(testClass2);

        TestClass<Object> testClass3=new TestClass<>();
        test1(testClass3);

    }

/*    public static void test1(TestClass<Number> testClass) {
        // 可以获取具体的泛型对象
        Number number = testClass.getE();
        System.out.println("test1...");
    }*/

    public static void test1(TestClass<?> testClass) {
        // 一旦使用泛型通配符,那么泛型类型通通提升为Object
        Object number = testClass.getE();
        System.out.println("test1...");
    }

/*    public static void test1(TestClass<Integer> testClass) {
        // 可以获取具体的泛型对象
        Number number = testClass.getE();
        System.out.println("test1...");
    }*/
}

class TestClass<E> {
    private E e;

    public E getE() {
        return e;
    }

    public void setE(E e) {
        this.e = e;
    }
}